<?php 
if(!defined('ADMIN')){
	exit('Access Denied');
}


?>
<form id="pagerForm" method="post" action="#rel#">
	<input type="hidden" name="pageNum" value="<?=$page?>" />
	<input type="hidden" name="numPerPage" value="<?=$pagesize?>" />
	<input type="hidden" name="orderField" value="<?=$orderField?>" />
	<input type="hidden" name="orderDirection" value="<?=$orderDirection?>" />
</form>
<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?=u(MOD,'category')?>" method="post">
</form>
<div class="pageHeader">
	<p><b>栏目管理</b></p>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="add" href="<?=u(MOD,'addedicategory')?>" target="dialog"><span>新建菜谱分类</span></a></li>
			<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids[]" href="<?=u(MOD,'delcategory')?>" class="delete"><span>批量删除</span></a></li>
			<li class="line">line</li>
		</ul>
	</div>
<form method="post" action="<?=u(MOD,'category')?>&id=<?=$id?>" rel="pagerForm"  onsubmit="return navTabSearch(this);">
<input type="hidden" name="sub" value="save" />
    
     <table class="table" width="100%" layoutH="110">
     <thead>
                    <tr>
                      <th width="3%"><input type="checkbox" group="ids[]" class="checkboxCtrl" /></th>
                      <th width="5%">排序</th>
					  <th width="" class="left">分类名称</th>
                      <th width="20%">操作</th>
                    </tr>
	</thead>
    <tbody>                    
					<?php 
                    
                    function listcategory($parentid=0){
                        global $ezhand,$modellist;
                        $total=$ezhand->count("shopping3_category","parentid=".$parentid);
                        $row=$ezhand->select_all("shopping3_category",'*',"parentid=".$parentid." order by displayorder asc");
                        if(empty($row)){
                            return;
                        }
                        
                    
                    $i=1;
                    foreach ($row as $r){
                        $f="";    
                        $cosp="";
                        if($parentid>0){
                            $cosp="├─ ";
                            if($i==$total){
                                $cosp="└─ ";
                            }
                            
                        }   
                        $i++; 

                        if($r["level"]==1){
                            $f="&nbsp;&nbsp;&nbsp;&nbsp; ".$cosp;
                        }elseif($r["level"]==2){
                            $f="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ".$cosp;
                        }elseif($r["level"]==3){
                            $f="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$cosp;
                        }elseif($r["level"]==4){
                            $f="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$cosp;
                
                        }
                                    
                        ?>
					  <tr target="id" rel="<?=$r["id"]?>">
                        <td class="center"><input <?php if($r['sys']==1){?>title="系统数据，不准删除"  disabled="disabled"<?php }?> type='checkbox' name='ids[]' value='<?=$r["id"]?>' /></td>
                        <td class="center"><input type="text" style="width:40px" name="listorder[<?=$r[id]?>]" value="<?=$r["displayorder"]?>" /></td>
                        <td class=""><?=$f?><?=$r["name"]?></td>
						<td class="center">
                        
                        <a title="添加子分类"  href="<?=u(MOD,'addedicategory',array('parentid'=>$r['id']))?>" target="dialog"  class="btnAdd">添加子分类</a>
                        <a title="编辑"  href="<?=u(MOD,'addedicategory',array('id'=>$r['id']))?>" target="dialog" class="btnEdit">编辑</a>
                        
                        <a title="删除" target="ajaxTodo" href="<?=u(MOD,'delcategory',array('id'=>$r['id']))?>" class="btnDel">删除</a>
                       
                        </td>
					  </tr>
					<?php
    
                           listcategory($r["id"]);
                          
                        }
                    
                    }
                    
                    listcategory(0);
                    ?>
                    </tbody>
                  </table>
<div class="formBar">
<ul style="float:left;">
<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保 存 排 序 </button></div></div></li>
</ul>
</div>
</form>                        

</div>  
